package org.example.myleet.rosalind.iev;

import java.math.BigDecimal;

public class Solution {
    public BigDecimal dominantPhenotypeExpectation(String input) {
        int[] numbers = new int[6];
        String[] numberStrings = input.split(" ");
        for (int i = 0; i < 6; ++i) {
            numbers[i] = Integer.parseInt(numberStrings[i]);
        }
        //Dominant probability: 0-AAxAA-100%, 1-AAxAa-100%, 2-AAxaa-100%, 3-AaxAa-75%, 4-Aaxaa-50%, 5-aaxaa-0%(ignore)
        //Every pair produce 2 offsprings
        BigDecimal p = BigDecimal.ZERO;
        p = p
                .add(BigDecimal.valueOf(numbers[0] * 2L))
                .add(BigDecimal.valueOf(numbers[1] * 2L))
                .add(BigDecimal.valueOf(numbers[2] * 2L))
                .add(BigDecimal.valueOf(numbers[3] * 2L).multiply(BigDecimal.valueOf(0.75)))
                .add(BigDecimal.valueOf(numbers[4] * 2L).multiply(BigDecimal.valueOf(0.5)));
        return p;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.dominantPhenotypeExpectation("1 0 0 1 0 1"));
        System.out.println(solution.dominantPhenotypeExpectation("16121 16269 17838 19349 18790 16205"));
    }
}
